using System;

using Mindscape.LightSpeed;
using Mindscape.LightSpeed.Validation;
using Mindscape.LightSpeed.Linq;

namespace OrmSmackdown.LightSpeedORM.Mappings
{
  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("Addresses", IdColumnName="AddressId")]
  [System.ComponentModel.DataObject]
  public partial class Address : Entity<int>
  {
    #region Fields
  
    private bool _isDefault;
    [ValidatePresence]
    [ValidateLength(0, 128)]
    private string _line1;
    [ValidatePresence]
    [ValidateLength(0, 128)]
    private string _city;
    [ValidatePresence]
    [ValidateLength(0, 2)]
    private string _state;
    [ValidatePresence]
    [ValidateLength(0, 5)]
    private string _zipCode;
    [ValidatePresence]
    [ValidateLength(0, 4)]
    private string _zipCodePlusFour;
    [ValidateLength(0, 128)]
    private string _line2;
    private int _personId;

    #endregion
    
    #region Field attribute and view names
    
    public const string IsDefaultField = "IsDefault";
    public const string Line1Field = "Line1";
    public const string CityField = "City";
    public const string StateField = "State";
    public const string ZipCodeField = "ZipCode";
    public const string ZipCodePlusFourField = "ZipCodePlusFour";
    public const string Line2Field = "Line2";
    public const string PersonIdField = "PersonId";


    #endregion
    
    #region Relationships

    [ReverseAssociation("Addresses")]
    private readonly EntityHolder<Person> _person = new EntityHolder<Person>();


    #endregion
    
    #region Properties

    public Person Person
    {
      get { return Get(_person); }
      set { Set(_person, value); }
    }


    public bool IsDefault
    {
      get { return Get(ref _isDefault, "IsDefault"); }
      set { Set(ref _isDefault, value, "IsDefault"); }
    }

    public string Line1
    {
      get { return Get(ref _line1, "Line1"); }
      set { Set(ref _line1, value, "Line1"); }
    }

    public string City
    {
      get { return Get(ref _city, "City"); }
      set { Set(ref _city, value, "City"); }
    }

    public string State
    {
      get { return Get(ref _state, "State"); }
      set { Set(ref _state, value, "State"); }
    }

    public string ZipCode
    {
      get { return Get(ref _zipCode, "ZipCode"); }
      set { Set(ref _zipCode, value, "ZipCode"); }
    }

    public string ZipCodePlusFour
    {
      get { return Get(ref _zipCodePlusFour, "ZipCodePlusFour"); }
      set { Set(ref _zipCodePlusFour, value, "ZipCodePlusFour"); }
    }

    public string Line2
    {
      get { return Get(ref _line2, "Line2"); }
      set { Set(ref _line2, value, "Line2"); }
    }

    public int PersonId
    {
      get { return Get(ref _personId, "PersonId"); }
      set { Set(ref _personId, value, "PersonId"); }
    }

    #endregion
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("Companies", IdColumnName="CompanyId")]
  [System.ComponentModel.DataObject]
  public partial class Company : Entity<int>
  {
    #region Fields
  
    [ValidatePresence]
    [ValidateLength(0, 50)]
    private string _companyName;

    #endregion
    
    #region Field attribute and view names
    
    public const string CompanyNameField = "CompanyName";


    #endregion
    
    #region Relationships

    [ReverseAssociation("Company")]
    private readonly EntityCollection<Person> _people = new EntityCollection<Person>();


    #endregion
    
    #region Properties

    public EntityCollection<Person> People
    {
      get { return Get(_people); }
    }


    public string CompanyName
    {
      get { return Get(ref _companyName, "CompanyName"); }
      set { Set(ref _companyName, value, "CompanyName"); }
    }

    #endregion
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("Performance", IdColumnName = "PerformanceId")]
  [System.ComponentModel.DataObject]
  public partial class Performance : Entity<int>
  {
      #region Fields

      [ValidatePresence]
      [ValidateLength(0, 128)]
      private string _ormName;

      [ValidatePresence]
      [ValidateLength(0, 128)]
      private string _action;

      private int _milliSeconds;
      #endregion

      #region Field attribute and view names

      public const string OrmNameField = "OrmName";
      public const string ActionField = "Action";
      public const string MilliSecondsField = "CompanyName";

      #endregion

      #region Properties


      public string OrmName
      {
          get { return Get(ref _ormName, "OrmName"); }
          set { Set(ref _ormName, value, "OrmName"); }
      }

      public string Action
      {
          get { return Get(ref _action, "OrmName"); }
          set { Set(ref _action, value, "OrmName"); }
      }

      public int MilliSeconds
      {
          get { return Get(ref _milliSeconds, "MilliSeconds"); }
          set { Set(ref _milliSeconds, value, "MilliSeconds"); }
      }

      #endregion
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("People", IdColumnName="PersonId")]
  [System.ComponentModel.DataObject]
  public partial class Person : Entity<int>
  {
    #region Fields
  
    [ValidatePresence]
    [ValidateLength(0, 50)]
    private string _firstName;
    [ValidatePresence]
    [ValidateLength(0, 50)]
    private string _lastName;
    [ValidatePresence]
    [ValidateEmailAddress]
    [ValidateLength(0, 128)]
    private string _email;
    [ValidatePresence]
    [ValidateLength(0, 2)]
    private string _userType;
    private System.Nullable<int> _companyId;
    private System.Nullable<int> _managerPersonId;
    private System.Nullable<int> _roleId;

    #endregion
    
    #region Field attribute and view names
    
    public const string FirstNameField = "FirstName";
    public const string LastNameField = "LastName";
    public const string EmailField = "Email";
    public const string UserTypeField = "UserType";
    public const string CompanyIdField = "CompanyId";
    public const string ManagerPersonIdField = "ManagerPersonId";
    public const string RoleIdField = "RoleId";


    #endregion
    
    #region Relationships

    [ReverseAssociation("Person")]
    private readonly EntityCollection<Address> _addresses = new EntityCollection<Address>();
    [ReverseAssociation("ManagerPerson")]
    private readonly EntityCollection<Person> _people = new EntityCollection<Person>();
    [ReverseAssociation("AdminUser")]
    private readonly EntityCollection<Portal> _portals = new EntityCollection<Portal>();
    [ReverseAssociation("Person")]
    private readonly EntityCollection<PortalPeopleXrefL> _portalPeopleXrefLs = new EntityCollection<PortalPeopleXrefL>();
    [ReverseAssociation("People")]
    private readonly EntityHolder<Company> _company = new EntityHolder<Company>();
    [ReverseAssociation("People")]
    private readonly EntityHolder<Person> _managerPerson = new EntityHolder<Person>();
    [ReverseAssociation("People")]
    private readonly EntityHolder<Role> _role = new EntityHolder<Role>();

    private ThroughAssociation<PortalPeopleXrefL, Portal> _portalsForPerson;

    #endregion
    
    #region Properties

    public EntityCollection<Address> Addresses
    {
      get { return Get(_addresses); }
    }

    public EntityCollection<Person> People
    {
      get { return Get(_people); }
    }

    public EntityCollection<Portal> Portals
    {
      get { return Get(_portals); }
    }

    public EntityCollection<PortalPeopleXrefL> PortalPeopleXrefLs
    {
      get { return Get(_portalPeopleXrefLs); }
    }

    public Company Company
    {
      get { return Get(_company); }
      set { Set(_company, value); }
    }

    public Person ManagerPerson
    {
      get { return Get(_managerPerson); }
      set { Set(_managerPerson, value); }
    }

    public Role Role
    {
      get { return Get(_role); }
      set { Set(_role, value); }
    }

    public ThroughAssociation<PortalPeopleXrefL, Portal> PortalsForPerson
    {
      get
      {
        if (_portalsForPerson == null)
        {
          _portalsForPerson = new ThroughAssociation<PortalPeopleXrefL, Portal>(_portalPeopleXrefLs);
        }
        return Get(_portalsForPerson);
      }
    }
    

    public string FirstName
    {
      get { return Get(ref _firstName, "FirstName"); }
      set { Set(ref _firstName, value, "FirstName"); }
    }

    public string LastName
    {
      get { return Get(ref _lastName, "LastName"); }
      set { Set(ref _lastName, value, "LastName"); }
    }

    public string Email
    {
      get { return Get(ref _email, "Email"); }
      set { Set(ref _email, value, "Email"); }
    }

    public string UserType
    {
      get { return Get(ref _userType, "UserType"); }
      set { Set(ref _userType, value, "UserType"); }
    }

    public System.Nullable<int> CompanyId
    {
      get { return Get(ref _companyId, "CompanyId"); }
      set { Set(ref _companyId, value, "CompanyId"); }
    }

    public System.Nullable<int> ManagerPersonId
    {
      get { return Get(ref _managerPersonId, "ManagerPersonId"); }
      set { Set(ref _managerPersonId, value, "ManagerPersonId"); }
    }

    public System.Nullable<int> RoleId
    {
      get { return Get(ref _roleId, "RoleId"); }
      set { Set(ref _roleId, value, "RoleId"); }
    }

    #endregion  
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("Portals", IdColumnName="PortalId")]
  [System.ComponentModel.DataObject]
  public partial class Portal : Entity<int>
  {
    #region Fields
  
    [ValidatePresence]
    [ValidateLength(0, 50)]
    private string _portalName;
    private int _adminUserId;

    #endregion
    
    #region Field attribute and view names
    
    public const string PortalNameField = "PortalName";
    public const string AdminUserIdField = "AdminUserId";


    #endregion
    
    #region Relationships

    [ReverseAssociation("Portal")]
    private readonly EntityCollection<PortalPeopleXrefL> _portalPeopleXrefLs = new EntityCollection<PortalPeopleXrefL>();
    [ReverseAssociation("Portals")]
    private readonly EntityHolder<Person> _adminUser = new EntityHolder<Person>();

    private ThroughAssociation<PortalPeopleXrefL, Person> _peopleInPortal;

    #endregion
    
    #region Properties

    public EntityCollection<PortalPeopleXrefL> PortalPeopleXrefLs
    {
      get { return Get(_portalPeopleXrefLs); }
    }

    public Person AdminUser
    {
      get { return Get(_adminUser); }
      set { Set(_adminUser, value); }
    }

    public ThroughAssociation<PortalPeopleXrefL, Person> PeopleInPortal
    {
      get
      {
        if (_peopleInPortal == null)
        {
          _peopleInPortal = new ThroughAssociation<PortalPeopleXrefL, Person>(_portalPeopleXrefLs);
        }
        return Get(_peopleInPortal);
      }
    }
    

    public string PortalName
    {
      get { return Get(ref _portalName, "PortalName"); }
      set { Set(ref _portalName, value, "PortalName"); }
    }

    public int AdminUserId
    {
      get { return Get(ref _adminUserId, "AdminUserId"); }
      set { Set(ref _adminUserId, value, "AdminUserId"); }
    }

    #endregion
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("Roles", IdColumnName="RoleId")]
  [System.ComponentModel.DataObject]
  public partial class Role : Entity<int>
  {
    #region Fields
  
    [ValidatePresence]
    [ValidateLength(0, 50)]
    private string _roleName;
    private bool _isForPortal;
    private bool _isForContact;

    #endregion
    
    #region Field attribute and view names
    
    public const string RoleNameField = "RoleName";
    public const string IsForPortalField = "IsForPortal";
    public const string IsForContactField = "IsForContact";


    #endregion
    
    #region Relationships

    [ReverseAssociation("Role")]
    private readonly EntityCollection<Person> _people = new EntityCollection<Person>();


    #endregion
    
    #region Properties

    public EntityCollection<Person> People
    {
      get { return Get(_people); }
    }


    public string RoleName
    {
      get { return Get(ref _roleName, "RoleName"); }
      set { Set(ref _roleName, value, "RoleName"); }
    }

    public bool IsForPortal
    {
      get { return Get(ref _isForPortal, "IsForPortal"); }
      set { Set(ref _isForPortal, value, "IsForPortal"); }
    }

    public bool IsForContact
    {
      get { return Get(ref _isForContact, "IsForContact"); }
      set { Set(ref _isForContact, value, "IsForContact"); }
    }

    #endregion
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Discriminator(Attribute="UserType", Value="US")]
  [System.ComponentModel.DataObject]
  public partial class User : Person
  {
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Discriminator(Attribute="UserType", Value="CN")]
  [System.ComponentModel.DataObject]
  public partial class Contact : Person
  {
  }

  [Serializable]
  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  [Table("PortalPeopleXref_LS", IdColumnName="PortalPeopleXrefId")]
  [System.ComponentModel.DataObject]
  public partial class PortalPeopleXrefL : Entity<int>
  {
    #region Fields
  
    private int _personId;
    private int _portalId;

    #endregion
    
    #region Field attribute and view names
    
    public const string PersonIdField = "PersonId";
    public const string PortalIdField = "PortalId";


    #endregion
    
    #region Relationships

    [ReverseAssociation("PortalPeopleXrefLs")]
    private readonly EntityHolder<Person> _person = new EntityHolder<Person>();
    [ReverseAssociation("PortalPeopleXrefLs")]
    private readonly EntityHolder<Portal> _portal = new EntityHolder<Portal>();


    #endregion
    
    #region Properties

    public Person Person
    {
      get { return Get(_person); }
      set { Set(_person, value); }
    }

    public Portal Portal
    {
      get { return Get(_portal); }
      set { Set(_portal, value); }
    }


    public int PersonId
    {
      get { return Get(ref _personId, "PersonId"); }
      set { Set(ref _personId, value, "PersonId"); }
    }

    public int PortalId
    {
      get { return Get(ref _portalId, "PortalId"); }
      set { Set(ref _portalId, value, "PortalId"); }
    }

    #endregion
  }


  [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
  public partial class OrmSmackdownUnitOfWork : Mindscape.LightSpeed.UnitOfWork
  {
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
    public OrmSmackdownUnitOfWork()
    {
    }
    

    public System.Linq.IQueryable<Address> Addresses
    {
      get { return this.Query<Address>(); }
    }
    
    public System.Linq.IQueryable<Company> Companies
    {
      get { return this.Query<Company>(); }
    }
    
    public System.Linq.IQueryable<Person> People
    {
      get { return this.Query<Person>(); }
    }
    
    public System.Linq.IQueryable<Portal> Portals
    {
      get { return this.Query<Portal>(); }
    }
    
    public System.Linq.IQueryable<Role> Roles
    {
      get { return this.Query<Role>(); }
    }
    
    public System.Linq.IQueryable<User> Users
    {
      get { return this.Query<User>(); }
    }

    public System.Linq.IQueryable<Performance> Performance
    {
        get { return this.Query<Performance>(); }
    }
    
    public System.Linq.IQueryable<Contact> Contacts
    {
      get { return this.Query<Contact>(); }
    }
    
    public System.Linq.IQueryable<PortalPeopleXrefL> PortalPeopleXrefLs
    {
      get { return this.Query<PortalPeopleXrefL>(); }
    }
    
  }

}
